package com.jinlia.show.modules.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jinlia.show.modules.base.model.po.PayOrderPO;
import com.jinlia.show.modules.base.model.query.PayOrderQuery;
import com.jinlia.show.modules.base.model.vo.DeliveryOrderVO;
import com.jinlia.show.modules.base.model.vo.PayOrderVO;
import com.jinlia.show.modules.base.wxapp.entity.PayOrder;
import com.jinlia.show.modules.base.wxapp.service.PayOrderMapperService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/payOrder")
public class PayOrderController {
    @Autowired
    PayOrderMapperService payOrderMapperService;

    /**
     * 订单详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getBySaleOrder/{id}")
    public ResponseEntity<List<PayOrderPO>> getByOrderId(@PathVariable("id") Long id) {
        List<PayOrderPO> bySource = payOrderMapperService.getBySource(id);
        return ResponseEntity.ok(bySource);
    }

    /**
     * 订单列表
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public PayOrderVO getById(@PathVariable("id") Long id) {
        return payOrderMapperService.getVODetails(id);
    }
    @PostMapping("/getPage")
    public ResponseEntity<Page<PayOrderVO>> getPageVO(@RequestBody PayOrderQuery payOrderQuery) {
        Page<PayOrderVO> res = payOrderMapperService.getPageVO(payOrderQuery);
        return ResponseEntity.ok(res);
    }

    @PostMapping("/list")
    public List<PayOrderVO> getListVO(@RequestBody PayOrderQuery payOrderQuery) {
        return payOrderMapperService.getListVO(payOrderQuery);
    }
}
